<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle.ListHistoricoDocumentoTitle}"></h:outputText>
        </ui:define>
        <ui:define name="body">

            <h:panelGroup id="messagePanel" styleClass="ajustaListaMensagemErro"  layout="block">
                <h:messages errorStyle="color: red" infoStyle="color: green" layout="list"/>
            </h:panelGroup>

            <h:form id="formList" styleClass="jsfcrud_list_form">

                <p:growl id="messages" life="3000" />

                <h:panelGroup>  
                    <p:dataTable id="tbl" value="#{historicoDocumentoController.lista}" var="item"  paginator="true" rows="#{bundle.rows}" pageLinks="5" 
                                 currentPageReportTemplate="#{bundle.currentPageReportTemplateHistoricoDocumento}"  paginatorTemplate="#{bundle.paginatorTemplate}"
                                 rowsPerPageTemplate="#{bundle.rowsPerPageTemplate}"  paginatorPosition="#{bundle.paginatorPosition}" emptyMessage="#{bundle.ListHistoricoDocumentoEmpty}" rowKey="#{item.hdcId}" selection="#{historicoDocumentoController.selectedHistoricoDocumento}" selectionMode="single">
                        <p:column styleClass="firstColumn"  filterBy="#{item.hdcId}" sortBy="#{item.hdcId}" filterMatchMode="contains">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListHistoricoDocumentoTitle_hdcId}"/>
                            </f:facet>
                            <h:outputText value="#{item.hdcId}"/>
                        </p:column>
                        <p:column filterBy="#{item.hdcDt}" sortBy="#{item.hdcDt}" filterMatchMode="contains">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListHistoricoDocumentoTitle_hdcDt}"/>
                            </f:facet>
                            <h:outputText value="#{item.hdcDt}">
                                <f:convertDateTime pattern="#{bundle.patternApp}" />
                            </h:outputText>
                        </p:column>
                        <p:column exportable="true" style="display:none;" filterBy="#{item.hdcTxObservacao}" sortBy="#{item.hdcTxObservacao}" filterMatchMode="contains">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListHistoricoDocumentoTitle_hdcTxObservacao}"/>
                            </f:facet>
                            <h:outputText value="#{item.hdcTxObservacao}"/>
                        </p:column>
                        <p:column filterBy="#{item.hdcTopId}" sortBy="#{item.hdcTopId}" filterMatchMode="contains">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListHistoricoDocumentoTitle_hdcTopId}"/>
                            </f:facet>
                            <h:outputText value="#{item.hdcTopId}"/>
                        </p:column>
                        <p:column filterBy="#{item.hdcSdcId}" sortBy="#{item.hdcSdcId}" filterMatchMode="contains">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListHistoricoDocumentoTitle_hdcShdId}"/>
                            </f:facet>
                            <h:outputText value="#{item.hdcSdcId}"/>
                        </p:column>
                        <p:column filterBy="#{item.hdcTcmId}" sortBy="#{item.hdcTcmId}" filterMatchMode="contains">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListHistoricoDocumentoTitle_hdcTcmId}"/>
                            </f:facet>
                            <h:outputText value="#{item.hdcTcmId}"/>
                        </p:column>

                        <f:facet name="footer">                            
                            <p:commandButton id="createCommand" rendered="#{!autenticadorController.loginVisualizador}" ajax="false" icon="ui-icon-document" action="#{historicoDocumentoController.prepareCreate}" value="#{bundle.ListHistoricoDocumentoCreateLink}"/>
                            <p:commandButton id="viewCommand"  value="#{bundle.MsgVisualizar}" icon="ui-icon-search"  update=":formList:displayView" oncomplete="historicoDocumentoDialogView.show()" actionListener="#{historicoDocumentoController.prepareView}" />
                            <p:commandButton id="editCommand" ajax="false" action="#{historicoDocumentoController.prepareEdit}" value="#{bundle.ListHistoricoDocumentoEditLink}" icon="ui-icon-pencil" />
                            <p:commandButton id="deleteCommand" rendered="#{autenticadorController.loginAdmin}" onclick="confirmationDestroy.show()" value="#{bundle.ListHistoricoDocumentoDestroyLink}" type="button" icon="ui-icon-trash" />
                            
                            <p:commandButton id="excelExportAll" ajax="false" value="#{bundle.excelExportAll}" icon="ui-icon-script">
                                <p:dataExporter type="xls" target="tbl" fileName="#{bundle.excelExportAllFileName_HistoricoDocumento}"/>
                            </p:commandButton>
                            <p:commandButton id="excelExportPagAtual" ajax="false" value="#{bundle.excelExportPagAtual}" icon="ui-icon-calculator">
                                <p:dataExporter type="xls" target="tbl" fileName="#{bundle.excelExportPagAtualFileName_HistoricoDocumento}" pageOnly="true"/>
                            </p:commandButton>
                        </f:facet>

                    </p:dataTable>

                    <p:confirmDialog id="confirmDestroy" message="#{bundle.MsgConfirmDestroy_message}" header="#{bundle.MsgConfirmDestroy_header}" severity="alert" widgetVar="confirmationDestroy">
                        <p:commandButton id="confirm" ajax="false" value="#{bundle.MsgDialog_confirmar}"  oncomplete="confirmationDestroy.hide();" actionListener="#{historicoDocumentoController.destroy}" />
                        <p:commandButton id="decline"  value="#{bundle.MsgDialog_cancelar}" update="messages" onclick="confirmationDestroy.hide()" type="button"/>

                    </p:confirmDialog>

                    <p:dialog id="dialogView" header="#{bundle.HistoricoDocumentoDialogView_header}" widgetVar="historicoDocumentoDialogView" resizable="false"
                              width="500" >

                        <h:panelGrid id="displayView" columns="2" cellpadding="4">                          

                            <h:outputText value="#{bundle.ViewHistoricoDocumentoLabel_hdcId}"/>
                            <h:outputText value="#{historicoDocumentoController.selected.hdcId}" title="#{bundle.ViewHistoricoDocumentoTitle_hdcId}"/>
                            <h:outputText value="#{bundle.ViewHistoricoDocumentoLabel_hdcDt}"/>
                            <h:outputText value="#{historicoDocumentoController.selected.hdcDt}" title="#{bundle.ViewHistoricoDocumentoTitle_hdcDt}">
                                <f:convertDateTime pattern="#{bundle.patternApp}" />
                            </h:outputText>
                            <h:outputText value="#{bundle.ViewHistoricoDocumentoLabel_hdcTxObservacao}"/>
                            <h:outputText value="#{historicoDocumentoController.selected.hdcTxObservacao}" title="#{bundle.ViewHistoricoDocumentoTitle_hdcTxObservacao}"/>
                            <h:outputText value="#{bundle.ViewHistoricoDocumentoLabel_hdcTopId}"/>
                            <h:outputText value="#{historicoDocumentoController.selected.hdcTopId}" title="#{bundle.ViewHistoricoDocumentoTitle_hdcTopId}"/>
                            <h:outputText value="#{bundle.ViewHistoricoDocumentoLabel_hdcShdId}"/>
                            <h:outputText value="#{historicoDocumentoController.selected.hdcSdcId}" title="#{bundle.ViewHistoricoDocumentoTitle_hdcShdId}"/>
                            <h:outputText value="#{bundle.ViewHistoricoDocumentoLabel_hdcTcmId}"/>
                            <h:outputText value="#{historicoDocumentoController.selected.hdcTcmId}" title="#{bundle.ViewHistoricoDocumentoTitle_hdcTcmId}"/>

                            <h:outputLabel value="#{bundle.createBy}" for="nomeCriador" rendered="#{not empty historicoDocumentoController.criacaoHist.nomeUsuario}"/>
                            <h:outputText id="nomeCriador" value="#{historicoDocumentoController.criacaoHist.nomeUsuario}" rendered="#{not empty historicoDocumentoController.criacaoHist.nomeUsuario}"/>
                            <h:outputLabel value="#{bundle.createDate}" for="dataCriacao" rendered="#{not empty historicoDocumentoController.criacaoHist.dataHora}"/>
                            <h:outputText id="dataCriacao" value="#{historicoDocumentoController.criacaoHist.dataHora}" rendered="#{not empty historicoDocumentoController.criacaoHist.dataHora}"/>     
                            <h:outputLabel value="#{bundle.updateBy}" for="nomeAlterador" rendered="#{not empty historicoDocumentoController.alteracaoHist.nomeUsuario}"/>
                            <h:outputText id="nomeAlterador" value="#{historicoDocumentoController.alteracaoHist.nomeUsuario}" rendered="#{not empty historicoDocumentoController.alteracaoHist.nomeUsuario}"/>
                            <h:outputLabel value="#{bundle.updateDate}" for="dataAlteracao" rendered="#{not empty historicoDocumentoController.alteracaoHist.dataHora}"/>
                            <h:outputText id="dataAlteracao" value="#{historicoDocumentoController.alteracaoHist.dataHora}" rendered="#{not empty historicoDocumentoController.alteracaoHist.dataHora}" /> 

                        </h:panelGrid>
                    </p:dialog>

                </h:panelGroup>

            </h:form>
        </ui:define>
    </ui:composition>

</html>
